# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-matplotlib
_pkgname=matplotlib
pkgver=2.2.4
pkgrel=3
pkgdesc='Python plotting package.'
url='https://pypi.org/project/matplotlib/#files'
arch=('x86_64' 'aarch64')
license=('PSF')
depends=('python2' 'python2-six' 'python2-cycler' 'python2-pyparsing'
         'python2-numpy' 'python2-pytz' 'python2-subprocess32'
         'python2-dateutil' 'python2-backports.functools_lru_cache'
         'python2-kiwisolver' 'libpng' 'freetype2')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('968f5731b8a9a2c5575403c60d5b0a98a452b33094e520be44f4d901f892d082babc8fc1d73c519e1ff2baf756f3cb7652f4b796e166d66dfda31f7e50c58139')

prepare() {
  cd "$_pkgname-$pkgver"

  find . -name '*.py' |
    xargs sed -i -e 's|/usr/bin/env python|/usr/bin/env python2|' \
    -e 's|/usr/bin/python|/usr/bin/python2|'
}

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

